﻿<%@ Page Language="C#" MasterPageFile="~/Template.master" AutoEventWireup="true"
    CodeFile="ShoppingCart.aspx.cs" Inherits="ShoppingCart" Title="Untitled Page"
    Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" %>

<%@ Import Namespace="Extensions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:Wizard ID="wizSubmitOrder" runat="server" ActiveStepIndex="0" CancelButtonText="Continue Shopping"
        CancelButtonType="Button" CancelDestinationPageUrl="~/default.aspx" DisplayCancelButton="True"
        DisplaySideBar="False" FinishPreviousButtonType="Button" StartNextButtonType="Button"
        Width="100%" StepNextButtonType="Button" StepPreviousButtonType="Button" FinishCompleteButtonType="Button"
        OnFinishButtonClick="wizSubmitOrder_FinishButtonClick" OnActiveStepChanged="wizSubmitOrder_ActiveStepChanged"
        meta:resourcekey="wizSubmitOrderResource1">
        <WizardSteps>
            <asp:WizardStep ID="WizardStep1" runat="server" Title="Shopping Cart" meta:resourcekey="WizardStep1Resource1">
                <div class="item floatbox">
                    <h5>
                        <asp:Label runat="server" ID="CartTitle" meta:resourcekey="CartTitle" /></h5>
                    <div class="CartItemList body">
                        <p style="text-align: left; padding: 5px 0px 0px 0px">
                            <asp:Literal ID="CartDescription" runat="server" meta:resourcekey="CartDescription" />
                        </p>
                        <asp:GridView Width="100%" ID="gvwOrderItems" runat="server" AutoGenerateColumns="False"
                            DataSourceID="objShoppingCart" DataKeyNames="ID" OnRowDeleted="gvwOrderItems_RowDeleted"
                            meta:resourcekey="gvwOrderItemsResource1" BorderWidth="0px">
                            <Columns>
                                <asp:TemplateField meta:resourcekey="ProductColumn" HeaderStyle-HorizontalAlign="Left">
                                    <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Left" />
                                    <ItemTemplate>
                                        <asp:HyperLink CssClass="ProductListItemTitle" NavigateUrl='<%# String.Format("Product.aspx?id={0}", Eval("ID")) %>'
                                            runat="server" Text='<%# Eval("Title") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderStyle-HorizontalAlign="Left" meta:resourcekey="TemplateFieldResource1">
                                    <ItemTemplate>
                                        <div style="text-align: left">
                                            <%# this.FormatPrice(Convert.ToDecimal(Eval("UnitPrice"))) %></div>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Quantity" meta:resourcekey="QuantityField">
                                    <HeaderStyle HorizontalAlign="Left" />
                                    <ItemTemplate>
                                        <div>
                                            <asp:TextBox runat="server" ID="txtQuantity" Text='<%# Bind("Quantity") %>' MaxLength="6"
                                                Width="30px" meta:resourcekey="txtQuantityResource1"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="valRequireQuantity" runat="server" ControlToValidate="txtQuantity"
                                                SetFocusOnError="True" Text="The Quantity field is required." ToolTip="The Quantity field is required."
                                                Display="Dynamic" meta:resourcekey="valRequireQuantityResource1"></asp:RequiredFieldValidator>
                                            <asp:CompareValidator ID="valQuantityType" runat="server" Operator="DataTypeCheck"
                                                Type="Integer" ControlToValidate="txtQuantity" Text="The Quantity must be an integer."
                                                ToolTip="The Quantity must be an integer." Display="Dynamic" meta:resourcekey="valQuantityTypeResource1" />
                                        </div>
                                    </ItemTemplate>
                                    <ItemStyle Width="60px" HorizontalAlign="Left" />
                                </asp:TemplateField>
                                <asp:TemplateField meta:resourcekey="TemplateFieldResource3">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <ItemTemplate>
                                        <asp:ImageButton runat="server" SkinID="DeleteButton" CommandName="Delete" meta:resourcekey="ImageButtonResource1" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <EmptyDataTemplate>
                                <b>
                                    <asp:Literal runat="server" ID="EmptyCartMessage" meta:resourcekey="EmptyCartMessage" /></b></EmptyDataTemplate>
                        </asp:GridView>
                        <asp:ObjectDataSource ID="objShoppingCart" runat="server" SelectMethod="GetItems"
                            TypeName="BLL.Store.CurrentUserShoppingCart" DeleteMethod="DeleteProduct"></asp:ObjectDataSource>
                        <asp:Panel runat="server" ID="panTotals" meta:resourcekey="panTotalsResource1">
                            <div style="text-align: right; font-weight: bold; padding-top: 4px;">
                                <asp:Literal runat="server" meta:resourcekey="lblSubtotal" />
                                <asp:Literal runat="server" ID="lblSubtotal" />
                                <p>
                                    <asp:Label runat="server" ID="lblShippingMethod" meta:resourcekey="lblShippingMethod" />
                                    <asp:DropDownList ID="ddlShippingMethods" runat="server" DataSourceID="objShippingMethods"
                                        DataTextField="Name" DataValueField="Price" meta:resourcekey="ddlShippingMethodsResource1">
                                    </asp:DropDownList>
                                </p>
                                <p>
                                    <asp:Literal runat="server" meta:resourcekey="lblTotal" />
                                    <asp:Literal runat="server" ID="lblTotal" />
                                    <asp:LinqDataSource ID="objShippingMethods" runat="server" ContextTypeName="DAL.EShopDBDataContext"
                                        TableName="ShippingMethods">
                                    </asp:LinqDataSource>
                                </p>
                                <asp:Button ID="btnUpdateTotals" runat="server" OnClick="btnUpdateTotals_Click" Text="Update totals"
                                    meta:resourcekey="btnUpdateTotalsResource1" />
                                <br />
                                <br />
                            </div>
                        </asp:Panel>
                    </div>
                </div>
            </asp:WizardStep>
            <asp:WizardStep ID="WizardStep2" runat="server" Title="Shipping Address" meta:resourcekey="WizardStep2Resource1">
                <h3>
                    <asp:Label runat="server" meta:resourcekey="ShippingAddressTitle" />
                </h3>
                <div class="CartItemList">
                    <asp:MultiView ID="mvwShipping" runat="server">
                        <asp:View ID="vwLoginRequired" runat="server">
                            <p style="text-align: left; padding: 5px 0px 0px 0px">
                                <asp:Literal runat="server" meta:resourcekey="NeedLoginMessage" />
                                <a href="CreateAccount.aspx">
                                    <asp:Literal runat="server" meta:resourcekey="NeedLoginMessage2" /></a>
                                <asp:Literal runat="server" meta:resourcekey="NeedLoginMessage3" />
                            </p>
                            <br />
                            <br />
                            <br />
                            <br />
                            <br />
                        </asp:View>
                        <asp:View ID="vwShipping" runat="server">
                            <p style="text-align: left">
                                <asp:Literal ID="Literal1" runat="server" meta:resourcekey="SheepingDescription" />
                            </p>
                            <div class="subcolumns">
                                <div class="c75l">
                                    <table>
                                        <tbody>
                                            <tr>
                                                <th>
                                                    <asp:Label runat="server" ID="lblFirstName" AssociatedControlID="txtFirstName" Text="First name:"
                                                        meta:resourcekey="lblFirstNameResource1" />
                                                </th>
                                                <td>
                                                    <asp:TextBox ID="txtFirstName" runat="server" Width="100%" meta:resourcekey="txtFirstNameResource1" />
                                                    <asp:RequiredFieldValidator ID="valRequireFirstName" runat="server" ControlToValidate="txtFirstName"
                                                        SetFocusOnError="true" Text="The First Name field is required." ToolTip="The First Name field is required."
                                                        Display="Dynamic" meta:resourcekey="valRequireFirstNameResource1"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>
                                                    <asp:Label runat="server" ID="lblLastName" AssociatedControlID="txtLastName" Text="Last name:"
                                                        meta:resourcekey="lblLastNameResource1" />
                                                </th>
                                                <td>
                                                    <asp:TextBox ID="txtLastName" runat="server" Width="100%" meta:resourcekey="txtLastNameResource1" />
                                                    <asp:RequiredFieldValidator ID="valRequireLastName" runat="server" ControlToValidate="txtLastName"
                                                        SetFocusOnError="true" Text="The Last Name field is required." ToolTip="The Last Name field is required."
                                                        Display="Dynamic" meta:resourcekey="valRequireLastNameResource1"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>
                                                    <asp:Label runat="server" ID="lblEmail" AssociatedControlID="txtEmail" Text="E-mail:"
                                                        meta:resourcekey="lblEmailResource1" />
                                                </th>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtEmail" Width="100%" meta:resourcekey="txtEmailResource1" />
                                                    <asp:RequiredFieldValidator ID="valRequireEmail" runat="server" ControlToValidate="txtEmail"
                                                        SetFocusOnError="true" Text="The E-mail field is required." ToolTip="The E-mail field is required."
                                                        Display="Dynamic" meta:resourcekey="valRequireEmailResource1"></asp:RequiredFieldValidator>
                                                    <asp:RegularExpressionValidator runat="server" ID="valEmailPattern" Display="Dynamic"
                                                        SetFocusOnError="true" ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                                        Text="The E-mail address you specified is not well-formed." ToolTip="The E-mail address you specified is not well-formed."
                                                        meta:resourcekey="valEmailPatternResource1"></asp:RegularExpressionValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>
                                                    <asp:Label runat="server" ID="lblPostalCode" AssociatedControlID="txtPostalCode"
                                                        Text="Zip / Postal code:" meta:resourcekey="lblPostalCodeResource1" />
                                                </th>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtPostalCode" Width="100%" meta:resourcekey="txtPostalCodeResource1" />
                                                    <asp:RequiredFieldValidator ID="valRequirePostalCode" runat="server" ControlToValidate="txtPostalCode"
                                                        SetFocusOnError="true" Text="The Postal Code field is required." ToolTip="The Postal Code field is required."
                                                        Display="Dynamic" meta:resourcekey="valRequirePostalCodeResource1"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>
                                                    <asp:Label runat="server" ID="lblState" AssociatedControlID="txtState" Text="State / Region:"
                                                        meta:resourcekey="lblStateResource1" />
                                                </th>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtState" Width="100%" meta:resourcekey="txtStateResource1" />
                                                    <asp:RequiredFieldValidator ID="valRequireState" runat="server" ControlToValidate="txtState"
                                                        SetFocusOnError="true" Text="The State field is required." ToolTip="The State field is required."
                                                        Display="Dynamic" meta:resourcekey="valRequireStateResource1"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>
                                                    <asp:Label runat="server" ID="lblCity" AssociatedControlID="txtCity" Text="City:"
                                                        meta:resourcekey="lblCityResource1" />
                                                </th>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtCity" Width="100%" meta:resourcekey="txtCityResource1" />
                                                    <asp:RequiredFieldValidator ID="valRequireCity" runat="server" ControlToValidate="txtCity"
                                                        SetFocusOnError="true" Text="The City field is required." ToolTip="The City field is required."
                                                        Display="Dynamic" meta:resourcekey="valRequireCityResource1"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>
                                                    <asp:Label runat="server" ID="lblStreet" AssociatedControlID="txtStreet" Text="Street:"
                                                        meta:resourcekey="lblStreetResource1" />
                                                </th>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtStreet" Width="100%" meta:resourcekey="txtStreetResource1" />
                                                    <asp:RequiredFieldValidator ID="valRequireStreet" runat="server" ControlToValidate="txtStreet"
                                                        SetFocusOnError="true" Text="The Street field is required." ToolTip="The Street field is required."
                                                        Display="Dynamic" meta:resourcekey="valRequireStreetResource1"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>
                                                    <asp:Label runat="server" ID="lblPhone" AssociatedControlID="txtPhone" Text="Phone:"
                                                        meta:resourcekey="lblPhoneResource1" />
                                                </th>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtPhone" Width="100%" meta:resourcekey="txtPhoneResource1" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>
                                                    <asp:Label runat="server" ID="lblFax" AssociatedControlID="txtFax" Text="Fax:" meta:resourcekey="lblFaxResource1" />
                                                </th>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtFax" Width="100%" meta:resourcekey="txtFaxResource1" />
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <br />
                            <br />
                        </asp:View>
                    </asp:MultiView>
                </div>
            </asp:WizardStep>
            <asp:WizardStep ID="WizardStep3" runat="server" Title="Order Confirmation" meta:resourcekey="WizardStep3Resource1">
                <h3>
                    <asp:Label runat="server" meta:resourcekey="OrderSummaryTitle" /></h3>
                <div class="CartItemList">
                    <p style="text-align: left; padding-top: 5px">
                        <asp:Literal runat="server" meta:resourcekey="OrderSummaryDescription" />
                    </p>
                    <b>
                        <asp:Label runat="server" meta:resourcekey="OrderDetailsLabel" /></b>
                    <p>
                    </p>
                    <asp:Repeater runat="server" ID="repOrderItems" DataSourceID="objShoppingCart">
                        <ItemTemplate>
                            <%# Eval("Title") %>-
                            <%# this.FormatPrice(Convert.ToDecimal(Eval("UnitPrice"))) %>&nbsp;&nbsp;<small>(<asp:Literal
                                runat="server" meta:resourcekey="QuantityLabel" />=
                                <%# Eval("Quantity") %>)</small>
                            <br />
                        </ItemTemplate>
                    </asp:Repeater>
                    <br />
                    <asp:Literal runat="server" meta:resourcekey="finishSubtotalLabel" />
                    =
                    <asp:Literal runat="server" ID="lblReviewSubtotal" meta:resourcekey="lblReviewSubtotalResource1" />
                    <p>
                    </p>
                    <asp:Literal runat="server" meta:resourcekey="FinishShippingMethodLabel" />
                    =
                    <asp:Literal runat="server" ID="lblReviewShippingMethod" meta:resourcekey="lblReviewShippingMethodResource1" />
                    <p>
                    </p>
                    <u>
                        <asp:Literal runat="server" meta:resourcekey="FinishTotalLabel" /></u> =
                    <asp:Literal runat="server" ID="lblReviewTotal" />
                    <p>
                    </p>
                    <b>
                        <asp:Literal runat="server" meta:resourcekey="ShippingDetails" /></b>
                    <p>
                    </p>
                    <asp:Literal runat="server" ID="lblReviewFirstName" meta:resourcekey="lblReviewFirstNameResource1" />
                    <asp:Literal runat="server" ID="lblReviewLastName" meta:resourcekey="lblReviewLastNameResource1" /><br />
                    <asp:Literal runat="server" ID="lblReviewStreet" meta:resourcekey="lblReviewStreetResource1" /><br />
                    <asp:Literal runat="server" ID="lblReviewCity" meta:resourcekey="lblReviewCityResource1" />,
                    <asp:Literal runat="server" ID="lblReviewState" meta:resourcekey="lblReviewStateResource1" />
                    <asp:Literal runat="server" ID="lblReviewPostalCode" meta:resourcekey="lblReviewPostalCodeResource1" /><br />
                    <asp:Literal runat="server" ID="lblReviewCountry" meta:resourcekey="lblReviewCountryResource1" />
                    <br />
                    <br />
                    <br />
                    <br />
                </div>
            </asp:WizardStep>
        </WizardSteps>
        <StepNextButtonStyle Font-Bold="True" />
        <StartNextButtonStyle Font-Bold="True" />
        <FinishCompleteButtonStyle Font-Bold="True" />
        <FinishPreviousButtonStyle Font-Bold="True" />
    </asp:Wizard>
</asp:Content>
